const module = {
    x: 42,
    getX() {
        try {
            return this.x;
        } catch(e) {
            console.log('error:', e.message);
        }
    }
}

const unboundGetX = module.getX;
console.log(unboundGetX());

const boundGetX = unboundGetX.bind(module);
console.log(boundGetX());

// settimeout
function LateBloomer() {
    this.petalCount = Math.floor(Math.random() * 12) + 1;
}

LateBloomer.prototype.bloom = function() {
    setTimeout(this.declare.bind(this), 1000);
}

LateBloomer.prototype.declare = function() {
    console.log(`I am a beautiful flower with ${this.petalCount} petals!`);
}

const flower = new LateBloomer();
flower.bloom();
